<!--
@Time:2021/12/2 20:36
@File:edit_article.py
@Author:常雷
@Software:PyCharm
-->
<!--
@Time:2021/12/1 7:52
@File:add_article.py
@Author:常雷
@Software:PyCharm
-->
{% extends 'backend/back_base.html' %}
<title>BBS-编辑文章</title>

{% block article %}
    <h3>添加文章</h3>
    {# 直接利用form表单提交数据 #}
    <form action="" method="post">
        {% csrf_token %}
        <p>标题:</p>
        <div style="width: 60%">
            <input type="text" name="title" class="form-control">
        </div>
        <p>内容:</p>
        <div>
            <textarea name="content" id="id_content" cols="30" rows="10"></textarea>
        </div>
        <p>分类:</p>
        <div>
            {% for category in category_list %}
                <input type="radio" value="{{ category.pk }}" name="category">{{ category.name }}
            {% endfor %}
        </div>
        <p>标签:</p>
        <div>
            {% for tag in tag_list %}
                <input type="checkbox" value="{{ tag.pk }}" name="tag">{{ tag.name }}
            {% endfor %}
        </div>
        <input type="submit" class="btn btn-danger">
    </form>
{% endblock %}

{% block js %}
    {% load static %}
    <script charset="utf-8" src="{% static 'kindeditor/kindeditor-all-min.js' %}"></script>
    <script>
        KindEditor.ready(function (K) {
            window.editor = K.create('#id_content', {
                width: '90%',
                height: '400px',
                items: [
                    'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
                    'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink', '|', 'about'
                ],//默认就是全参数
                resizeType:1,
                uploadJson : '/upload_image/', //上传图片的后端提交路径
                {#allowFileManager : true,#}
                extraFileUploadParams : {
                    {#item_id : 1000,#}
                    {#category_id : 1,#}
                    'csrfmiddlewaretoken':'{{ csrf_token }}'
                }
            });
        });
    </script>
{% endblock %}